<?php
/**
 * JumpTo - A Download System for Content Pages. Work in Joomla 1.0.x & Joostina.
 * @author:      Лаборатория сайтов
 * @version:     1.3
 * @release:     2009.12.20
 * @package:     com_jumpto
 * @copyright:   (C) 2009 http://sitelab.net.ru
 * @license:     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 *
 * Cоздан на базе Registered Downloads  (C) 2006 by St. John Johnson
 **/

#-Запрет прямого доступа-#
defined( '_VALID_MOS' ) or die();

class JumpTo_HTML {
	function showFiles( $option, &$rows, &$search, &$pageNav ) {
		?>
<form action="index2.php" method="post" name="adminForm">
	<table class="adminheading">
		<tbody><tr>
				<th class="edit"><?php echo JUMPTO_FILES_LIST?></th>
				<td nowrap="nowrap"><?php echo _PN_DISPLAY_NR?> # </td>
				<td><?php echo $pageNav->writeLimitBox(); ?></td>
				<td><?php echo _FILTER?>: </td>
				<td>
					<input type="text" name="search" value="<?php echo htmlspecialchars($search); ?>" class="inputbox" onChange="document.adminForm.submit();" />
				</td>
			</tr>
	</table>
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
        <tr>
			<th width="2%" class="title"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" /></th>
			<th class="title"><div align="left">ID</div></th>
			<th class="title"><div align="left"><?php echo JUMPTO_FILE_NAME?></div></th>
			<th class="title"><div align="left"><?php echo JUMPTO_LINK?></div></th>
			<th class="title"><div align="left"><?php echo JUMPTO_COUNTS?></div></th>
			<th class="title"><div align="left"><?php echo JUMPTO_ONLY_FOR_REG?></div></th>
        </tr>
				<?php
				$k = 0;
				for ($i=0, $n=count( $rows ); $i < $n; $i++) {
					$row = &$rows[$i];
					echo "<tr class='row$k'>";
					echo "<td width='20px'><input type='checkbox' id='cb$i' name='cid[]' value='$row->id' onclick='isChecked(this.checked);' /></td>";
					echo "<td align='left'>".$row->id."</td>";
					echo "<td align='left'><a href=\"index2.php?option=".$option."&task=edit&cid=".$row->id."\">".$row->name."</a></td>";
					echo "<td align='left'>$row->url</td>";
					echo "<td align='left'>$row->count</td>";
					echo "<td align='left'>".($row->reg?JUMPTO_YES:JUMPTO_NO)."</td></tr>";
					$k = 1 - $k;
				} ?>
		<tr>
			<th align="center" colspan="7"><?php echo $pageNav->writePagesLinks(); ?></th>
		</tr>
		<tr>
			<td align="center" colspan="7"><?php echo $pageNav->writePagesCounter(); ?></td>
		</tr>
    </table>
    <input type="hidden" name="option" value="<?php echo $option;?>" />
    <input type="hidden" name="task" value="" />
    <input type="hidden" name="boxchecked" value="0" />
</form>
		<?php
	}


	function editFiles( $option, &$row ) {
		?>
<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		if (form.url.value == ""){
			alert( "<?php echo JUMPTO_NEED_LINK?>" );
		} else if (form.name.value == ""){
			alert( "<?php echo JUMPTO_NEED_NAME?>" );
		} else if (isNaN(form.count.value) == true) {
			alert( "<?php echo JUMPTO_COUNTS_NOT_INT?>" );
		} else {
			submitform( pressbutton );
		}
	}
</script>
<table class="adminheading">
	<tr>
        <th width="100%" class="edit"><?php echo $row->id ? JUMPTO_EDITING : JUMPTO_ADDING;?> <?php echo JUMPTO_FILE?></th>
	</tr>
</table>
<form action="index2.php" method="post" name="adminForm" id="adminForm">
    <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
		<tr>
			<td width="20%" align="right"><?php echo JUMPTO_FILE_NAME?>:</td>
			<td width="80%">
				<input class="inputbox" type="text" name="name" size="50" maxlength="150" value="<?php echo $row->name;?>" />
			</td>
		</tr>
		<tr>
			<td valign="top" align="right"><?php echo JUMPTO_LINK?>:</td>
			<td>
				<input class="inputbox" type="text" name="url" value="<?php echo $row->url; ?>" size="50" maxlength="150" />
			</td>
		</tr>
		<tr>
			<td valign="top" align="right"><?php echo JUMPTO_COUNTS?>:</td>
			<td>
				<input class="inputbox" type="text" name="count" value="<?php echo $row->count; ?>" size="50" maxlength="150" />
			</td>
		</tr>
		<tr>
			<td valign="top" align="right"><?php echo JUMPTO_ONLY_FOR_REG?>:</td>
			<td>
				<input name="reg" id="reg_1" type="radio" value="1"<?php echo $row->reg ? 'checked' : '';?> /><label for="reg_1"><?php echo JUMPTO_YES_ONLY_FOR_REG?></label>><br />
					<input name="reg" id="reg_0" type="radio" value="0"<?php echo $row->reg ? '' : 'checked';?> /><label for="reg_0"><?php echo JUMPTO_NO_ONLY_FOR_REG?></label>
			</td>
		</tr>
    </table>
    <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
    <input type="hidden" name="option" value="<?php echo $option;?>" />
    <input type="hidden" name="task" value="" />
</form>
		<?php
	}
}